let User = require("../models/user.js");
let haveUser = function(name,password){
	return new Promise((resolve, reject) => {
		User.findOne(name,function(err,data){
			if(err){
				reject({"error": err});
			}else if(data.length == 0){
				reject({"error": "没有此用户"});
			}else if(data[0].password != password){
				reject({"error": "密码错误"});
			}else{
				resolve(data);
			}
		});
	});
}
module.exports = haveUser;